| Total Complexity | 8 |
| Total Lines | 35 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | import fse from 'fs-extra'; |
||
| 9 | export default class Test { |
||
| 10 | createAPI(url = 'http://mock/', opts = {}) { |
||
| 11 | return new API(url, opts); |
||
| 12 | } |
||
| 13 | |||
| 14 | async setTmpFolder() { |
||
| 15 | await fse.ensureDir(tmpFolder); |
||
| 16 | } |
||
| 17 | |||
| 18 | async cleanTmpFolder() { |
||
| 19 | await fse.remove(tmpFolder); |
||
| 20 | } |
||
| 21 | |||
| 22 | mockAPI() { |
||
| 23 | mockAPI(); |
||
| 24 | } |
||
| 25 | |||
| 26 | unMockAPI() { |
||
| 27 | unMockAPI(); |
||
| 28 | } |
||
| 29 | |||
| 30 | async startMockApp() { |
||
| 31 | this._server = await startMockApp(); |
||
| 32 | } |
||
| 33 | |||
| 34 | get mockAppUrl() { |
||
| 35 | const { port } = this._server.address(); |
||
| 36 | |||
| 37 | return `http://localhost:${port}`; |
||
| 38 | } |
||
| 39 | |||
| 40 | async stopMockApp() { |
||
| 41 | await stopMockApp(this._server); |
||
| 42 | } |
||
| 43 | } |
||
| 44 | |||
| 45 |